package com.ruoyi.project.module.maxAttribute.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.module.maxAttribute.domain.MaxAttribute;
import com.ruoyi.project.module.maxAttribute.service.IMaxAttributeService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * 属性配置 信息操作处理
 * 
 * @author ruoyi
 * @date 2021-02-16
 */
@Controller
@RequestMapping("/module/maxAttribute")
public class MaxAttributeController extends BaseController
{
    private String prefix = "module/maxAttribute";
	
	@Autowired
	private IMaxAttributeService maxAttributeService;
	
	@RequiresPermissions("module:maxAttribute:view")
	@GetMapping()
	public String maxAttribute()
	{
	    return prefix + "/maxAttribute";
	}
	
	/**
	 * 查询属性配置列表
	 */
	@RequiresPermissions("module:maxAttribute:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(MaxAttribute maxAttribute)
	{
		startPage();
        List<MaxAttribute> list = maxAttributeService.selectMaxAttributeList(maxAttribute);
		return getDataTable(list);
	}
	
	/**
	 * 新增属性配置
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存属性配置
	 */
	@RequiresPermissions("module:maxAttribute:add")
	@Log(title = "属性配置", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(MaxAttribute maxAttribute)
	{		
		return toAjax(maxAttributeService.insertMaxAttribute(maxAttribute));
	}

	/**
	 * 修改属性配置
	 */
	@GetMapping("/edit/{maxAttributeId}")
	public String edit(@PathVariable("maxAttributeId") Long maxAttributeId, ModelMap mmap)
	{
		MaxAttribute maxAttribute = maxAttributeService.selectMaxAttributeById(maxAttributeId);
		mmap.put("maxAttribute", maxAttribute);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存属性配置
	 */
	@RequiresPermissions("module:maxAttribute:edit")
	@Log(title = "属性配置", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(MaxAttribute maxAttribute)
	{		
		return toAjax(maxAttributeService.updateMaxAttribute(maxAttribute));
	}
	
	/**
	 * 删除属性配置
	 */
	@RequiresPermissions("module:maxAttribute:remove")
	@Log(title = "属性配置", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(maxAttributeService.deleteMaxAttributeByIds(ids));
	}
	
}
